<template>
	<view>
		<navNav :navobj="navobj"></navNav>

		<view class="actList">
			<view class="item" @click="goagreement()">
				<view style="display: flex;align-items: center;">
					<image class="img" src="../../static/img/user/dianpu.png"></image>
					<view class="name">服务协议</view>
				</view>
				<uni-icons class="icon" type="right"></uni-icons>
			</view>
			<view class="item">
				<view style="display: flex;align-items: center;">
					<image class="img" src="../../static/img/user/dianpu.png"></image>
					<view class="name">资格执照</view>
				</view>
				<uni-icons class="icon" type="right"></uni-icons>
			</view>
		</view>

		<view class="actList">
			<view class="item" @click="clear">
				<view style="display: flex;align-items: center;">
					<image class="img" src="../../static/img/user/dianpu.png"></image>
					<view class="name">清理缓存</view>
				</view>
				<view>
					{{data}}.00kb
					<uni-icons class="icon" type="right"></uni-icons>
				</view>
			</view>
			<view class="item">
				<view style="display: flex;align-items: center;">
					<image class="img" src="../../static/img/user/dianpu.png"></image>
					<view class="name">当前版本</view>
				</view>
				<view>
					{{banben}}
					<uni-icons class="icon" type="right"></uni-icons>
				</view>
			</view>
		</view>

		<view class="buttonBox" @click="tcdl">
			退出登录
		</view>
	</view>
</template>

<script setup>
	import {reactive,ref,getCurrentInstance,onMounted} from 'vue'
	import {onLoad} from "@dcloudio/uni-app"
	import {storeToRefs} from "pinia";//结构才需要引入
	import {userStore} from '@/store/user.js'//引入空间
	const userStores = userStore()//给空间命名
	const {user,balance} = storeToRefs(userStores);//解构数据
	const {proxy} = getCurrentInstance()
	const navobj = reactive({
				title:'设置',
				image:true
	})
	const data=ref(0)
	const banben=ref("1.0.0")
	onLoad(()=>{
	  data.value = Math.floor(Math.random() * (100 - 20 + 1)) + 20
		// #ifdef MP-WEIXIN
		var accountInfo = wx.getAccountInfoSync()
		banben.value = accountInfo.plugin.version
		// #endif
	}) 
		
	const goagreement=()=>{
		uni.navigateTo({
			url:'/pages-user/agreement/agreement?id='+1
		})
	}
	const navTo=(url)=> {
		uni.navigateTo({
			url: url
		})
	}
	const clear=()=>{
		uni.showModal({
			title: '是否清理缓存',
			success: (e) => {
				console.log(e);
				if (e.confirm) {
					data.value = 0
					uni.showToast({
						title: '清理成功',
						icon: 'none'
					})
				}
			}
		})
	}
	//退出登录
	const tcdl=()=>{
		uni.showModal({
			title: '确定退出登录吗？',
			content: '',
			success: function(res) {
				if (res.confirm) {
					uni.clearStorageSync();
					uni.reLaunch({
						url: '/pages-login/login/login'
					});
				} else if (res.cancel) {
					console.log('用户点击取消');
				}
			}
		})
}
	
	
</script>

<style lang="scss" scoped>
	.buttonBox {
		background-color: $blue;
		color: white;
		margin: 20px 20px;
		border-radius: 50px;
		padding: 12px 0;
		text-align: center;
		font-weight: bold;
	}

	.actList {
		background-color: white;
		margin: 10px 0px;

		.item {
			padding: 15px 20px;
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-bottom: 1px solid $MainBackColor;

			.img {
				width: 20px;
				height: 20px;
				margin-right: 10px;
			}

			.name {
				font-size: 15px;
			}

			.icon {
				font-weight: bold;
			}
		}
	}

	body {
		background-color: $MainBackColor;
	}
</style>